package com.tiger.jms.sample2;

import javax.naming.*;
import javax.jms.*;

public class Sender {
	public static void main(String[] args) {
		try {
			InitialContext ctx = new InitialContext();
			QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
			QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
			QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
			Queue queue = (Queue) ctx.lookup("queue/sampleQueue");
			QueueSender queueSender = queueSession.createSender(queue);

			queueConnection.start();
			queueSender.send(queueSession.createTextMessage("Hello"));

			queueSender.close();
			queueSession.close();
			queueConnection.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
